package main.java.auxiliary.service;

import main.java.auxiliary.CommonUtils;
import main.java.base.BaseElement;
import main.java.base.ElementService;
import main.java.content.player.Player;
import main.java.content.substance.Buaa;
import main.java.base.IHurtPlayer;

/**
 * @author 吴浩华 陈逸然 吴畏
 * @Description: 陷阱和漂浮物
 * @date 2021/6/12
 */
public class SubstanceElementService extends ElementService {

    public SubstanceElementService() {
        //添加掉落的buaa校训
        CommonUtils.task(3 * 1000, () -> {
            this.add(new Buaa());
        });
    }

    @Override
    protected boolean encounterPlayer(BaseElement element, Player player) {
        if (element instanceof IHurtPlayer) {//陷阱统一处理
            if (element.intersects(player)) {
                player.beHurt();
                return true;
            }
        }
        return super.encounterPlayer(element, player);
    }
}
